//
//  YiDaLocation.swift
//  YiDa
//
//  Created by zhoufei on 16/6/26.
//  Copyright © 2016年 ZhouFei. All rights reserved.
//

import Foundation

class YiDaLocation: NSObject {
    var lat:Double = 0
    var lng:Double = 0
    var address:String = ""
    
    class var main:YiDaLocation
        {
            struct Static {
                static let instance:YiDaLocation = YiDaLocation()
            } 
            return Static.instance
    }
    
    
    func saveDefault(){
        let param:Dictionary<String,AnyObject> = ["lat":self.lat,"lng":self.lng,"address":self.address]
        
        NSUserDefaults.standardUserDefaults().setValue(param, forKey: LOCATION_DEFAULT)
    }
    
    func getDefault() -> Dictionary<String,AnyObject>?{
        if let param:Dictionary<String,AnyObject> = NSUserDefaults.standardUserDefaults().dictionaryForKey(LOCATION_DEFAULT)!{
            self.lat = (param["lat"]?.doubleValue)!
            self.lng = (param["lng"]?.doubleValue)!
            self.address = (param["address"]?.stringValue)!
            return param
        }
        return nil
    }
}
